import { User } from "src/user/user.entity";
import { Column, Entity, JoinColumn, JoinTable, ManyToMany, PrimaryGeneratedColumn } from "typeorm";

@Entity()
export class Roles {
    @PrimaryGeneratedColumn()
    id: number;
    

    @Column()
    name: string;

    @ManyToMany(() => User, (user) => user.roles)
    @JoinTable({
        name: 'users_roles',
        inverseJoinColumn: {
            name: 'useId',
            referencedColumnName: 'id',
        },
        joinColumn: {
            name: 'roleId',
            referencedColumnName: 'id',
        },
    })
    users: User[];
}